import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { DepartmentsService } from './departments.service';
import { CreateDepartmentDto } from './dto/create-department.dto';
import { UpdateDepartmentDto } from './dto/update-department.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('部门')
@Controller('departments')
export class DepartmentsController {
  constructor(private readonly departmentsService: DepartmentsService) {}

  @ApiOperation({ summary: '创建部门' })
  @Post('create')
  create(@Body() createDepartmentDto: CreateDepartmentDto) {
    return this.departmentsService.create(createDepartmentDto);
  }

  @ApiOperation({ summary: '查询所有部门' })
  @Get('queryAll')
  findAll() {
    return this.departmentsService.findAll();
  }

  @ApiOperation({ summary: '根据ID查询部门' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.departmentsService.findOne(+id);
  }

  @ApiOperation({ summary: '编辑部门' })
  @Post('update')
  update(@Body() updateDepartmentDto: UpdateDepartmentDto) {
    return this.departmentsService.update(updateDepartmentDto);
  }

  @ApiOperation({ summary: '删除部门' })
  @Post(':id')
  remove(@Param('id') id: string) {
    return this.departmentsService.remove(+id);
  }
}
